<style type="text/css">
@import "/scripts/jquery.datepick.package-3.7.5/css/jquery.datepick.css";
</style>

<script type="text/javascript" src="/scripts/common.js"></script>
<script src="/scripts/jquery.fcbkcomplete.js" type="text/javascript" charset="utf-8"></script>
<link type="text/css" href="/styles/ui-lightness/jquery-ui-1.8.16.custom.css" rel="stylesheet" />
<link type="text/css" href="/styles/styles.css" rel="stylesheet" />
<link href="/styles/timepicker.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="/scripts/jquery.datepick.package-3.7.5/js/jquery.datepick.js"></script>
<script type="text/javascript" src="/scripts/timepicker.js"></script>

<link rel="stylesheet" href="/styles/thickbox.css" />
<script type="text/javascript" src="/scripts/thickbox.js"></script>
<div id="blockContIn">
<table border="0" cellspacing="0" cellpadding="0" align="left">
  <tr>
    <td valign="top"><div class="Col">
	<tal:block tal:content="structure php: this.partial('index/myactivityview.html')"/>
</div></td>
	<td valign="top" width="100%"><div class="ColExp">
<div class="ModuleBlock" style="height:1020px">
<h1>
<label>Task-Personal</label>
<div><a href="/tasks/settings/task-settings"><img src="/images/SettingsIcon.png" border="0" alt="Settings" title="Settings" align="top" class="SetIcon"/></a>
<a href="/tasks/index/task-list"  ><img src="/images/HomeIcon.png" alt="Home" width="15" height="17" border="0" align="top" class="SetIcon" title="Home"/></a>
</div>
</h1>
<div class="clear"></div>
<ul class="ModuleMenu">
<?php if($ctx->type==1) { ?>
<li><a href="/tasks/index/task-list/<?php echo $ctx->type; ?>" class="active">Task-Personal</a> </li>
<? } else if($ctx->type==2) {?>
<li><a href="/tasks/index/task-list/<?php echo $ctx->type; ?>" class="active">Assigned To</a> </li>
<? } else {?>
<li><a href="/tasks/index/task-list/<?php echo $ctx->type; ?>" class="active">Assigned By</a> </li>
<? } ?>
</ul>
<div class="clear hig20"></div>
<div class="ListWid">
<div class="blkCont">
				<tal:block tal:content="structure php: this.partial('/index/task-view-list.html')"/>
			
</div>
</div>
<div class="Fleft wid55per" >
<table width="100%" border="0" cellspacing="0" cellpadding="0" >
  <tr>
    <td>
	<div>
	<div class="BotBorder">
<div class=" pad_b15">
	<div class="Fright">
	<?php if($ctx->type==3){ ?>
    <select id="status" class="wid150 txt12 GryBorder fontGry" onChange="changeStatus(this)">
	<?php if($ctx->taskDetails['TaskRelations'][0]['task_status']=="isprogress") { ?>
    <option value="" selected="selected">Select Status</option>
	<? } else { ?>
	<option value="">Select Status</option>
	<?  } if($ctx->taskDetails['TaskRelations'][0]['task_status']=="completed") { ?>
    <option value="1" selected="selected">Completed</option>
	<? } else { ?>
	 <option value="1" >Completed</option>
	 <?  } if($ctx->taskDetails['TaskRelations'][0]['task_status']=="accepted")  { ?>
    <option value="2" selected="selected">Accepted</option>
	<? } else { ?>
	 <option value="2">Accepted</option>
	<?  } if($ctx->taskDetails['TaskRelations'][0]['task_status']=="rejected") { ?>
    <option value="3" selected="selected">Rejected</option>
	<? } else { if($ctx->type!=1) { ?>
	<option value="3">Rejected</option>
	<? } } ?>
    </select>
	<? } ?>
	<?php if($ctx->type==1 || $ctx->type==2){ ?>
   <a  class="BtGray" id="create" href="javascript:void(0);" onclick="createTask();">Edit</a>
   <? } ?>
   <?php if($ctx->type==1)
   {
   $name="";
   $id=$ctx->taskDetails['task_id'];
	$type="task_id";
   }
   else if($ctx->type==2)
   {
	$name=$ctx->taskDetails['task_name']." assign to ".$ctx->taskDetails['name'];
	 $id=$ctx->taskDetails['task_id'];
	 $type="task_id";
   }
   else
   {
	$name=$ctx->taskDetails['task_name']." assign by ".$ctx->taskDetails['name'];
	$id=$ctx->taskDetails['TaskRelations'][0]['id'];
	$type="relation_id";
   }
   if(count($ctx->taskDetails['TaskRelations'][0]['MyFavorites'])>0)
	{
		$user_id = $ctx->taskDetails['TaskRelations'][0]['MyFavorites']['owner_id'];
		$favorite_status = $ctx->taskDetails['TaskRelations'][0]['MyFavorites']['status'];
		
		
	} else {
		$favorite_status = 'Inactive';
		$user_id = '';
	}
   
   ?>
<?php if($ctx->taskDetails['TaskRelations'][0]['priority']==0) { ?>
<span><a href="javascript:void(0);" onclick="changePriorityStatus(<?php echo $ctx->taskDetails['TaskRelations'][0]['id'];?>,'1')"><img src="/images/Emot_4.png" alt="Priority" border="0" class="img_inline" title="Priority" /></a></span>
<?php } else{ ?>
<span><a href="javascript:void(0);" onclick="changePriorityStatus(<?php echo $ctx->taskDetails['TaskRelations'][0]['id'];?>,'0')"><img src="/images/Emot_7.png" alt="Priority" border="0" class="img_inline" title="Priority" /></a></span>
<?php } ?>
	 <?php if($favorite_status=="Active"&& $user_id==$_SESSION["sess_userid"]){?>
<a href="javascript:void(0);" onclick="changeStatusFavorite(<?php echo $ctx->taskDetails['task_id'];?>,'Inactive')"><img src="/images/FavorIconAct.png" alt="Favorite" title="Favorite" /></a>
<? } else {?>
<a href="javascript:void(0);" onclick="changeStatusFavorite(<?php echo $ctx->taskDetails['task_id'];?>,'Active')"><img src="/images/FavorIconNor.png" alt="Favorite" title="Favorite" /></a>
<? } ?>
<span><a href="javascript:void(0);" onclick="deleteTask(<?php echo $id;?>,'<?php echo $type;?>');"><img src="/images/CloseIcon.png" alt="Close" border="0" class="img_inline" title="Delete"/></a></span>
</div>
	<div class="clear"></div>
		</div>
	<div class="pad_bt5">
	<div class="Fleft">
    <p class="txt18"><?php echo $ctx->taskDetails['task_name'];?> <br /></p><br />
      <span class="txt14"><?php echo $name; ?></span>
	  
    <p class="txt_sm fontGry"><label><strong>Due Date: </strong></label><?php echo date($ctx->date_fromat,strtotime($ctx->taskDetails['due_date'])); ?>&nbsp;&nbsp;&nbsp;<label><strong>Budget:</strong> </label> $ <?php echo $ctx->taskDetails['cost']; ?></p>
	<?php if($ctx->taskDetails['eventName']!="") { ?>
	<span><a href="#" class="CaleLink"><?php echo $ctx->taskDetails['eventName'];?></a></span>
	<? } ?>
	</div>
    <div class="clear"></div>
	</div>
	<div class="clear"></div>	
	</div>
	
	<div class="pad_t15">
	
    <div class="Fright">
	
    <strong>Reccurance:</strong>&nbsp;<span class="txt_sm fontGry"><?php echo $ctx->taskDetails['Reccurance']; ?></span>
    </div>
    <div class="clear"></div>
    </div>
	<div class="pad_t15">
							<?php if($ctx->taskDetails['description']!="") { ?>
							<p><?php echo $ctx->taskDetails['description']; ?></p>
							<? } else { ?>
							<a class="Button" href="javascript:void(0);" onclick="showTextArea();"><span>Add Description</span></a>
							<div class="clear"></div>
							<div id="div1">
							</div>
							<? } ?>
		<div class="clear"></div>
	</div>
    
    <div class="clear"></div>
	<?php if($ctx->type!=1) { ?>
	<div  class="LtGray GryBorder">
    <p><strong>Assignees</strong></p>
    <div class="pad_t5">
	<?php foreach($ctx->assignees as $assignees) { ?>
    <div class="AsgList"><img src="/Uploads/users/<?php echo $assignees['photo']; ?>" height="45px" width="40px"/></div>
	<? } ?>
	<div class="clear"></div>
      </div>
       <div class="clear"></div>
      </div>
	  
       <div class="clear"></div>
	   <div class="pad_t15"><strong>Author</strong></div>
	   <? } ?>
     </div>
	 <?php if($ctx->type!=1){ ?>
	 <div class="pad_t15" id="listContent">
	<tal:block tal:content="structure php: this.partial('/index/task-comments.html')"/>
	</div>
 <div id="downPagerId" class="paginat" style="padding-right:15px;"></div>
 <div class="clear"></div>
	<? } ?>
	</td>
  </tr>
</table>
</div>
<div class="clear"></div>
</div>
</div></td>
<td valign="top">
<div class="ColBanner">
<div class="ModuleBlock">
<img src="/images/Gads.gif" /><img src="/images/Gads.gif" /></div>
</div></td>	
</tr>
</table>





<div class="clear"></div>
</div>

<script type="text/javascript">
//<![CDATA[
pagination = new Array();
	pagination['currentPage'] = "<?=$ctx->getComments['currentPage']?>";
	pagination['resultsPerPage'] = "<?=$ctx->getComments['resultPerPage']?>";
	pagination['pages'] = "<?= $ctx->getComments['pages']?>";  
	pagination['pager'] = '<?=$ctx->getComments["pager"]?>';
	pagination['resultsCount'] = "${getComments/resultsCount}" ;
	
	var Params='${params}';
	//alert(pagination['resultsCount']+'  '+Params);
	var requestUrl = "/tasks/index/pagination/<?php echo $ctx->taskDetails['task_id'];?>/";
	$(document).ready(function () {
	   setPagination(pagination['resultsCount'],'','downPagerId','','');
	});

function deleteTask(id,action)
{
	//alert(id+"and"+action);return false;
	$.ajax({
			   
			    type: "POST",
				dataType: "json",
			    data: "val="+id+"&action="+action+"&current_page="+<?php echo $ctx->currentPage; ?>+"&type="+<?php echo $ctx->type ; ?>,
			    url: "/tasks/index/delete-tasks/",
			    success: function(data){
						window.location = "/tasks/index/task-list/<?php echo $ctx->type ; ?>";
							
				}
			});
}

function changeStatusFavorite(task_id,status)
{
	//alert(trigger_id+"and"+status);return false;
	$.ajax({
			   
			    type: "POST",
				dataType: "json",
			    data: "trigger_id="+task_id+"&status="+status+"&type=tasks",
			    url: "/triggers/index/favorite/",
			    success: function(data){
					location.reload();					
				}
			});
}
function createTask()
{
	tb_show('Edit Task','/tasks/index/create-task?&edit=edit&task_id='+<?php echo $ctx->taskDetails['task_id'];?>+'&event_name='+"<?php echo $ctx->taskDetails['eventName'];?>"+'&height=350&width=650','');
}
function navigate(e) {
   
if(e.keyCode == 13)
{	
	var comment=$("#comment");			  //enter pressed
     //submitComment(comment);
	 }
  }
  
document.onkeypress=navigate;
function submitComment(comment,photo_id)
{
	//alert(id+"and"+action);return false;
	$.ajax({
			   
			    type: "POST",
				dataType: "json",
			    data: "photo_id="+photo_id+"&album_id="+<?php echo $ctx->taskDetails['task_id'];?>+"&comment="+comment.value+"&type=tasks",
			    url: "/tasks/index/submit-comment/",
			    success: function(data){
					if(data.output== 1)
					{
						location.reload();
					}
					
				}
			});
}
function changeStatus(val) 
{ 
	if($("#status").val()=="")
	{
		return false;
	}
		//alert($("#group").val());return false;
		var getVal = $("#status").val();
	$.ajax({
			type: "POST",
			dataType: "json",
			data: "val="+getVal+"&userId=<?php echo $ctx->taskDetails['TaskRelations'][0]['id'];?>",
			//alert(a);return false;
			url: "/tasks/index/change-status/",
			success: function(data){
			//alert(data.output);return false;
					if(data.output)
					{
					alert('task status changed to: '+data.output);
					}
					else
					{
					alert('fail change task_status ')
					}
					location.reload();					
				}
		}); 
} 
function deleteComment(comment_id,photo_id)
{
     //alert(comment_id);return false;
	$.ajax({
			   
			    type: "POST",
				dataType: "json",
				data: "comment_id="+comment_id+"&type=album&album_id="+<?php echo $ctx->taskDetails['task_id'];?>+"&photo_id="+photo_id+"&current_page="+<?php echo $ctx->getComments['currentPage']?>,
				url: "/album/index/delete-comment",
			    success: function(data){
						location.reload();
						
				}
			});
}
function showTextArea()
{
	//alert(obj.value);return false;
	document.getElementById('div1').innerHTML = '<div class="pad_t15"><textarea id="description" name="description"></textarea><p><a class="Button" href="javascript:void(0);" onclick="addTaskDescription(<?php echo $ctx->taskDetails['task_id']; ?>);"><span>Add</span></a></p></div>'

}
function addTaskDescription(task_id)
{
	var description=document.getElementById('description').value;
	//alert(description+"and"+photo_id);return false;
	$.ajax({
			   
			    type: "POST",
				dataType: "json",
			    data: "task_id="+task_id+"&description="+description,
			    url: "/tasks/index/add-description/",
			    success: function(data){
					location.reload();
					}					
				
			});
}
function changePriorityStatus(realtion_id,status)
{
	//alert(trigger_id+"and"+status);return false;
	$.ajax({
			   
			    type: "POST",
				dataType: "json",
			    data: "realtion_id="+realtion_id+"&status="+status+"&type=tasks",
			    url: "/tasks/index/change-priority-status/",
			    success: function(data){
					location.reload();					
				}
			});
}
//]]>
</script>
